package o;

import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.graphics.Paint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.card.base.bean.AppInfoBean;
import com.huawei.hwphy2d.physical.util.BarrierParameters;
import java.util.List;
import o.ewm.d;
import o.ewm.h;
import o.ewm.j;
import o.ewm.n;

public class diz {

    class c implements OnClickListener {
        private CheckBox ˊ;
        private AppInfoBean ˎ;
        final /* synthetic */ diz ˏ;

        public c(diz o_diz, CheckBox checkBox, AppInfoBean appInfoBean) {
            this.ˏ = o_diz;
            this.ˊ = checkBox;
            this.ˎ = appInfoBean;
        }

        public void onClick(View view) {
            this.ˏ.ˋ(this.ˊ, this.ˎ);
        }
    }

    @TargetApi(16)
    public View ˊ(Context context, int i, int i2, AppInfoBean appInfoBean, int i3) {
        View inflate = LayoutInflater.from(context).inflate(h.ᐧᐝ, null);
        LinearLayout linearLayout = (LinearLayout) inflate.findViewById(j.ˍᐧ);
        linearLayout.setContentDescription(appInfoBean.ʽ());
        CheckBox checkBox = (CheckBox) inflate.findViewById(j.ʴ);
        TextView textView = (TextView) inflate.findViewById(j.ॱʻ);
        textView.setImportantForAccessibility(2);
        textView.setText(appInfoBean.ʽ());
        TextView textView2 = (TextView) inflate.findViewById(j.ˎˏ);
        textView2.setImportantForAccessibility(2);
        ImageView imageView = (ImageView) inflate.findViewById(j.ˋᐝ);
        imageView.setImportantForAccessibility(2);
        eqx.ˏ(imageView, appInfoBean.ˋॱ(), "app_default_icon");
        if (((cdg) cdb.ॱ(cdg.class)).ॱॱ(appInfoBean.ˏॱ())) {
            checkBox.setVisibility(8);
            textView2.setText(n.ꜞᐝ);
            imageView.setAlpha(BarrierParameters.FRICTION);
            imageView.setOnClickListener(null);
            textView.setAlpha(BarrierParameters.FRICTION);
            textView2.setAlpha(BarrierParameters.FRICTION);
        } else {
            checkBox.setVisibility(0);
            textView2.setText(appInfoBean.ᐝॱ());
            imageView.setAlpha(1.0f);
            ˏ(imageView, checkBox, appInfoBean);
            textView.setAlpha(1.0f);
            textView2.setAlpha(1.0f);
        }
        ˊ((ImageView) inflate.findViewById(j.ॱˋ), textView2, appInfoBean.ʼ());
        if ("2".equals(appInfoBean.ʾ())) {
            checkBox.setChecked(true);
            diy.ˊ().ˊ(appInfoBean.ˏॱ(), appInfoBean);
        } else {
            checkBox.setChecked(false);
        }
        if ((i2 % i != 0 ? 1 : null) != null) {
            if (MinimumFactory.getBoolValue(ContentManager.getInstant().getContext())) {
                linearLayout.setPadding(0, 0, i3, 0);
            } else {
                linearLayout.setPadding(i3, 0, 0, 0);
            }
        }
        return inflate;
    }

    private void ˊ(ImageView imageView, TextView textView, List<String> list) {
        if (imageView != null && textView != null) {
            LayoutParams layoutParams = textView.getLayoutParams();
            int i = 1;
            String str = "";
            if (CollectCheck.isEmpty((List) list)) {
                i = 0;
            } else {
                str = (String) list.get(0);
                if (dni.ˏ(str)) {
                    i = 0;
                }
            }
            if (i == 0) {
                imageView.setVisibility(8);
                layoutParams.width = -1;
                return;
            }
            imageView.setVisibility(0);
            eqx.ˏ(imageView, str, "iconflag");
            Paint paint = new Paint();
            paint.setTextSize(textView.getTextSize());
            float measureText = paint.measureText(textView.getText().toString());
            i = textView.getResources().getDimensionPixelSize(d.ˎˏ);
            if (measureText < ((float) i)) {
                layoutParams.width = -2;
            } else {
                layoutParams.width = i;
            }
        }
    }

    private void ˏ(ImageView imageView, CheckBox checkBox, AppInfoBean appInfoBean) {
        imageView.setOnClickListener(new c(this, checkBox, appInfoBean));
        checkBox.setOnClickListener(new c(this, checkBox, appInfoBean));
    }

    private void ˋ(CheckBox checkBox, AppInfoBean appInfoBean) {
        if ("2".equals(appInfoBean.ʾ())) {
            checkBox.setChecked(false);
            appInfoBean.ˏॱ("1");
            diy.ˊ().ˎ(appInfoBean.ˏॱ());
        } else {
            checkBox.setChecked(true);
            appInfoBean.ˏॱ("2");
            diy.ˊ().ˊ(appInfoBean.ˏॱ(), appInfoBean);
        }
        Intent intent = new Intent("com.huawei.appmarket.broadcast.updateroamnumchange");
        intent.putExtra("updatezjbbsize", diy.ˊ().ˋ().size());
        ll.ˏ(ContentManager.getInstant().getContext()).ˋ(intent);
    }

    public LinearLayout ॱ(Context context) {
        LinearLayout linearLayout = new LinearLayout(context);
        linearLayout.setOrientation(0);
        return linearLayout;
    }
}
